<?php

if(!defined('IN_refrigeratory')) {
	exit('Access Denied');
}

$operation = $_REQUEST["operation"];
$operations = array("info_equipment");

if (!in_array($operation, $operations)){
	echo '{"success":false, "info":"request params invalid"}';
	exit;
}

if ($operation == "info_equipment"){
	$id_storage = $_REQUEST["id_storage"];
	$sql = "SELECT e.id_equipment,e.identifier,t.temp,t.time 
			FROM  t_equipment e ,t_temp t 
			WHERE e.id_storage = $id_storage
			AND t.id_equipment = e.id_equipment 
			AND t.time = ( 
				SELECT time FROM t_temp child WHERE child.id_equipment = t.id_equipment 
				ORDER BY time DESC LIMIT 0,1
			)";
	echo get_json_from_sql($sql);
}

?>